home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / progs / editor / frexxed / fpl / examineline.fpl < prev    next >
Text File  |  1995-07-18  |  2KB  |  70 lines

  1. export void ExamineLine()
  2. {
  3.   int ret;
  4.  
  5.   {
  6.                         // Try to with 'ParenMatch()'
  7.     int chr=GetChar();
  8.     if (Isclose(chr)>=0 || Isopen(chr)>=0) {
  9.       ret=MatchParen();
  10.       ReturnStatus(GetReturnMsg(ret));
  11.       return;                    // Exit
  12.     }
  13.   }
  14.  
  15.   {                        // Try to find an include file
  16.     string line;
  17.     string filename;
  18.     int counter=10;
  19.     int length;
  20.   
  21.     line=GetLine();
  22.     length=strlen(line);
  23.   
  24.     if (!Stricmp("#include ", line, 9)) {
  25.       while (counter<length) {
  26.         if (line[counter]=='>' || line[counter]=='\"')
  27.           break;
  28.         filename=joinstr(filename, itoc(line[counter]));
  29.         counter++;
  30.       }
  31.       if (line[9]=='\"') {
  32.         if (Check(joinstr(ReadInfo("file_path"), filename)))
  33.           filename=joinstr(ReadInfo("file_path"), filename);
  34.         else
  35.           line[9]='<';
  36.       }
  37.   
  38.       if (line[9]=='<')
  39.         filename=joinstr("include:", filename);
  40.  
  41.       if (strlen(filename)) {        // Check that we have a filename.      
  42.         int newid, oldid;
  43.         oldid=GetEntryID();
  44.         newid=New();
  45.         if (newid) {
  46.           CurrentBuffer(newid);
  47.           ret=Load(filename);
  48.           if (ret<0) {            // Load error?
  49.             CurrentBuffer(oldid);
  50.             Kill(newid);
  51.             ReturnStatus(GetReturnMsg(ret));
  52.           } else {
  53.             CurrentBuffer(oldid);    // We swap the current buffer
  54.             Activate(newid);        // to get the new view a logic
  55.             CurrentBuffer(newid);    // position.
  56.           }
  57.         } else
  58.           ReturnStatus(GetReturnMsg(GetErrNo()));
  59.       }
  60.       return;                // Exit
  61.     } else {                // Not an include line.
  62.       ExecuteFile("Grep.FPL");        // Run Grep.
  63.     }
  64.   }
  65.   ReturnStatus(GetReturnMsg(ret));
  66. }
  67.  
  68. AssignKey("ExamineLine();", "Amiga p");
  69.  
  70.